% COMBINED
% updated April 24 2020 by ZJM
RegName = 'Combined';
VariablesT = { 'MgO' 'Na2O' 'TiO2' 'K2O' 'CaO'};
VariablesX = { '1-Mg#' 'NaK#' 'SiO2' 'K2O' 'CaO/Al2O3 wt%'};
VariablesP = {'Oliv'     '1-Mg#' 'Na2O' 'TiO2' 'K2O' 'CaO/Al2O3 wt%'};
newcoeffs_combined = [...
    1082.17261	9.73752	8.64885	-0.12571	16.85070	-10.43987	0.87319
    0.31324	0.00636	0.10841	-0.13473	-0.00468	-0.00074	0.07843
    -0.02683	-0.00214	-0.08708	0.38334	-0.00343	-0.00602	0.49905
    1.67145	-0.00615	-0.28740	0.42285	-0.01321	-0.07589	-0.51808
    -0.96665	0.00187	0.23654	-0.71553	0.02194	0.01959	-0.08205
    -13.24300	110.02839	-23.61882	2.09062	2.30139	1.95271	1.87059];
garnet_coefficients=newcoeffs_combined;
spinel_coefficients=newcoeffs_combined;
plagioclase_coefficients=newcoeffs_combined;
assignin('caller', sprintf('VariablesT_%s',RegName), VariablesT)
assignin('caller', sprintf('VariablesX_%s',RegName), VariablesX)
assignin('caller', sprintf('VariablesP_%s',RegName), VariablesP)
assignin('caller', sprintf('garnet_coefficients_%s',RegName), garnet_coefficients)
assignin('caller', sprintf('spinel_coefficients_%s',RegName), spinel_coefficients)
assignin('caller', sprintf('plagioclase_coefficients_%s',RegName), plagioclase_coefficients)


RegName = 'Combined_v2';
VariablesT = {'MgO' 'Na2O' 'SiO2' 'K2O' 'CaO'};
VariablesX = {'1-Mg#' 'Na2O' 'SiO2' 'K2O' 'CaO/Al2O3 wt%'};
VariablesP = {'Oliv'     '1-Mg#' 'Na2O' 'SiO2' 'K2O' 'CaO/Al2O3 wt%'};
newcoeffs_combined = [...
    1323.47323	8.19464	9.55953	-1.89611	-3.20471	-5.09863	-4.39378
    0.36434	0.00635	0.10453	-0.01403	-0.00482	-0.01262	0.03100
    -0.10819	-0.00141	-0.03921	0.02372	-0.00167	0.01732	0.47528
    1.54404	-0.00575	-0.25627	0.03570	-0.01207	-0.04398	-0.45094
    -0.80246	0.00063	0.15428	-0.04740	0.01892	-0.02599	-0.06823
    -17.90274	114.53771	-17.71486	2.20677	0.08376	2.17711	0.79440];
garnet_coefficients=newcoeffs_combined;
spinel_coefficients=newcoeffs_combined;
plagioclase_coefficients=newcoeffs_combined;
assignin('caller', sprintf('VariablesT_%s',RegName), VariablesT)
assignin('caller', sprintf('VariablesX_%s',RegName), VariablesX)
assignin('caller', sprintf('VariablesP_%s',RegName), VariablesP)
assignin('caller', sprintf('garnet_coefficients_%s',RegName), garnet_coefficients)
assignin('caller', sprintf('spinel_coefficients_%s',RegName), spinel_coefficients)
assignin('caller', sprintf('plagioclase_coefficients_%s',RegName), plagioclase_coefficients)


RegName = 'Combined_Sep';
VariablesT = {'MgO' 'Na2O' 'SiO2' 'K2O' 'CaO'};
VariablesX = {'1-Mg#' 'Na2O' 'SiO2' 'K2O' 'CaO/Al2O3 wt%'};
VariablesP = {'Oliv'     '1-Mg#' 'Na2O' 'SiO2' 'K2O' 'CaO/Al2O3 wt%'};

garnet_coefficients= ...
    [849.01632	2.10294	9.01669	-21.94572	16.52424	-24.98929	-25.24718
    0.42857	0.00645	0.21525	-0.01654	-0.00448	-0.02843	-0.09172
    0.01324	-0.00268	-0.13590	0.03308	-0.00305	0.00989	0.45400
    1.20920	-0.00636	-0.38977	0.04221	-0.00991	-0.01763	-0.11573
    -0.70935	0.00200	0.25799	-0.05718	0.01797	-0.02881	-0.18571
    -67.99349	130.07721	-30.98563	2.57218	0.79152	4.06141	21.07172];

spinel_coefficients= ...
    [1213.15812	10.47604	6.22438	-1.89183	-1.58766	-8.68079	-0.50543
    0.85004	0.00441	-0.00502	-0.00806	-0.01395	-0.00813	0.02231
    -0.07835	-0.00096	-0.02645	0.02455	-0.00302	0.01774	0.51370
    1.12443	-0.00442	-0.16798	0.03111	-0.00377	-0.04316	-0.46757
    -0.85229	0.00061	0.15338	-0.04892	0.02028	-0.02885	-0.08731
    11.00036	78.59851	-19.24514	2.00216	-0.29864	1.80656	-1.71334];


plagioclase_coefficients=...
    [993.41371	11.89527	-14.12456	10.19850	-2.83699	36.52759	36.27497
    0.43447	0.00295	0.06590	-0.01874	-0.00372	-0.02282	-0.09556
    -0.32295	0.00103	0.00549	0.01787	0.00250	0.00770	0.45292
    1.42285	-0.00132	-0.21092	0.04160	-0.01284	-0.03075	-0.29679
    -0.69714	-0.00074	0.12120	-0.04489	0.01716	-0.02196	-0.07167
    48.87803	30.91228	-11.55795	1.20624	-0.82588	0.96710	-6.25305];

assignin('caller', sprintf('VariablesT_%s',RegName), VariablesT)
assignin('caller', sprintf('VariablesX_%s',RegName), VariablesX)
assignin('caller', sprintf('VariablesP_%s',RegName), VariablesP)
assignin('caller', sprintf('garnet_coefficients_%s',RegName), garnet_coefficients)
assignin('caller', sprintf('spinel_coefficients_%s',RegName), spinel_coefficients)
assignin('caller', sprintf('plagioclase_coefficients_%s',RegName), plagioclase_coefficients)





% NEW
RegName = 'NEW';
VariablesT = { 'Mg#' 'NaK#' 'TiO2' 'K2O' 'CaO/Al2O3 wt%'};
VariablesX = { 'Mg#' 'NaK#' 'TiO2' 'K2O' 'CaO/Al2O3 wt%'};
VariablesP = {'Oliv' 'Mg#' 'NaK#' 'TiO2' 'K2O' 'CaO/Al2O3 wt%'};


% no 6GPa
% garnet_coefficients = [...
%    1160.25724	11.51601	109.29558	-50.62107	25.48682	-22.07090	-65.97520
% 0.53917	0.00758	-0.33950	-0.19580	-0.01145	-0.02296	-0.12190
% -0.19031	-0.00281	0.10225	0.35511	-0.00525	-0.01067	0.40971
% 0.59506	-0.00851	0.29536	0.38857	-0.01529	-0.04284	-0.21004
% 0.05697	0.00375	-0.05305	-0.55811	0.01741	0.01080	-0.08478
% -66.20359	118.18002	43.31542	25.51836	1.48285	2.66914	17.55403];


garnet_coefficients = [...
1136.36052	8.73915	184.88412	-19.48245	29.00187	-23.41730	-22.48205
0.53105	0.00664	-0.31382	-0.18522	-0.01025	-0.02342	-0.10713
-0.19232	-0.00305	0.10861	0.35773	-0.00495	-0.01078	0.41337
0.61340	-0.00638	0.23735	0.36467	-0.01798	-0.04181	-0.24342
0.04833	0.00275	-0.02572	-0.54685	0.01868	0.01032	-0.06905
-77.53423	139.87872	46.43963	28.72057	1.52179	3.25095	18.62211];


spinel_coefficients =   [...
    1049.24929	12.71243	63.47484	-3.32516	2.65802	-12.03128	117.75713
    0.29432	0.00879	-0.21515	-0.20805	-0.02668	-0.00335	0.04626
    -0.25601	-0.00049	0.01598	0.33606	-0.00051	-0.00570	0.52520
    0.82612	-0.00360	0.11628	0.39210	-0.01170	-0.07164	-0.48226
    0.14785	-0.00478	0.08470	-0.53037	0.02331	0.01994	-0.10667
    -29.49925	84.81760	24.99866	24.66609	2.78588	-0.13748	-1.84832];

plagioclase_coefficients = ...
    [1074.38633	11.86431	65.55420	-138.22714	20.55173	5.85532	79.01883
    0.41221	0.00526	-0.16238	-0.36336	-0.01093	-0.00063	-0.12587
    -0.25604	0.00036	0.03202	0.33938	-0.00408	-0.00956	0.49666
    0.42923	0.01181	0.13163	0.50259	0.00140	-0.07267	-0.15741
    0.42247	-0.01757	0.00135	-0.48658	-0.00104	0.02298	-0.22459
    -43.58532	136.94746	24.54202	37.54688	2.10967	-0.77250	1.63584];
assignin('caller', sprintf('VariablesT_%s',RegName), VariablesT)
assignin('caller', sprintf('VariablesX_%s',RegName), VariablesX)
assignin('caller', sprintf('VariablesP_%s',RegName), VariablesP)
assignin('caller', sprintf('garnet_coefficients_%s',RegName), garnet_coefficients)
assignin('caller', sprintf('spinel_coefficients_%s',RegName), spinel_coefficients)
assignin('caller', sprintf('plagioclase_coefficients_%s',RegName), plagioclase_coefficients)

% NEW
RegName = 'NEW_noOPX';
VariablesT = { 'Mg#' 'NaK#' 'TiO2' 'K2O' 'CaO/Al2O3 wt%'};
VariablesX = { 'Mg#' 'NaK#' 'TiO2' 'K2O' 'CaO/Al2O3 wt%'};
VariablesP = {'Oliv' 'Mg#' 'NaK#' 'TiO2' 'K2O' 'CaO/Al2O3 wt%'};

garnet_coefficients = [...
1192.01725	7.98062	172.69870	37.79005	7.43543	-23.69375	-48.03951
0.52617	0.00608	-0.27950	-0.20574	-0.01025	-0.01993	-0.11761
-0.06949	-0.00294	0.07850	0.28265	-0.00330	-0.00831	0.29923
0.41018	-0.00547	0.25854	0.57444	-0.00846	-0.05195	-0.08303
0.12391	0.00225	-0.04634	-0.65474	0.00936	0.01418	-0.09853
-78.02944	128.48621	44.26046	36.01766	1.77014	2.27467	26.12336];


spinel_coefficients =   [...
    1049.24929	12.71243	63.47484	-3.32516	2.65802	-12.03128	117.75713
    0.29432	0.00879	-0.21515	-0.20805	-0.02668	-0.00335	0.04626
    -0.25601	-0.00049	0.01598	0.33606	-0.00051	-0.00570	0.52520
    0.82612	-0.00360	0.11628	0.39210	-0.01170	-0.07164	-0.48226
    0.14785	-0.00478	0.08470	-0.53037	0.02331	0.01994	-0.10667
    -29.49925	84.81760	24.99866	24.66609	2.78588	-0.13748	-1.84832];

plagioclase_coefficients = ...
    [1074.38633	11.86431	65.55420	-138.22714	20.55173	5.85532	79.01883
    0.41221	0.00526	-0.16238	-0.36336	-0.01093	-0.00063	-0.12587
    -0.25604	0.00036	0.03202	0.33938	-0.00408	-0.00956	0.49666
    0.42923	0.01181	0.13163	0.50259	0.00140	-0.07267	-0.15741
    0.42247	-0.01757	0.00135	-0.48658	-0.00104	0.02298	-0.22459
    -43.58532	136.94746	24.54202	37.54688	2.10967	-0.77250	1.63584];
assignin('caller', sprintf('VariablesT_%s',RegName), VariablesT)
assignin('caller', sprintf('VariablesX_%s',RegName), VariablesX)
assignin('caller', sprintf('VariablesP_%s',RegName), VariablesP)
assignin('caller', sprintf('garnet_coefficients_%s',RegName), garnet_coefficients)
assignin('caller', sprintf('spinel_coefficients_%s',RegName), spinel_coefficients)
assignin('caller', sprintf('plagioclase_coefficients_%s',RegName), plagioclase_coefficients)


%%%% Till2012
RegName = 'TILL2012';
VariablesT = {'1-Mg#' 'NaK#' 'TiO2' 'K2O'};
VariablesP = {'Oliv' '1-Mg#' 'NaK#' 'TiO2' 'K2O'};
VariablesX = VariablesT;

garnet_coefficients = [...
    1306.25338	8.59986	-195.43810	0.50431	29.73476	-23.51487
    0.14156	0.00613	0.24803	-0.10598	-0.00261	-0.02147
    0.18491	-0.00031	0.07562	-0.01528	-0.01656	-0.00676
    0.69935	-0.00821	-0.32835	0.60024	-0.01547	-0.04723
    -0.02248	0.00229	-0.00394	-0.48282	0.02022	0.00955
    -14.45722	139.32776	-38.31577	12.04870	0.60944	3.10707];

spinel_coefficients =   [...
    1174.86601	14.27915	50.40218	-128.83143	-29.53198	-10.23105
    0.11630	0.00886	0.22266	-0.25998	-0.02594	-0.00272
    0.18161	0.00028	0.06917	-0.25345	0.00785	0.00150
    0.55522	-0.00430	-0.19446	0.93341	-0.01938	-0.07826
    0.14691	-0.00493	-0.10199	-0.41064	0.02161	0.01847
    -5.93189	84.44488	-25.23058	26.65497	2.74811	-0.16479];

plagioclase_coefficients = ...
    [1218.95394	9.23050	-66.28465	-159.15079	24.86548	-16.30899
    0.13292	0.00666	0.17025	-0.25378	-0.01273	0.00196
    0.23726	-0.00516	-0.06306	-0.09300	0.00303	-0.01976
    0.41466	0.01356	-0.12179	0.63963	-0.00085	-0.06944
    0.21522	-0.01507	0.01269	-0.29105	-0.00426	0.02760
    -17.15661	134.19121	-24.17698	35.42529	2.09860	-0.80149];

assignin('caller', sprintf('VariablesT_%s',RegName), VariablesT)
assignin('caller', sprintf('VariablesX_%s',RegName), VariablesX)
assignin('caller', sprintf('VariablesP_%s',RegName), VariablesP)
assignin('caller', sprintf('garnet_coefficients_%s',RegName), garnet_coefficients)
assignin('caller', sprintf('spinel_coefficients_%s',RegName), spinel_coefficients)
assignin('caller', sprintf('plagioclase_coefficients_%s',RegName), plagioclase_coefficients)


%% BBG2020
RegName = 'BBG2020';
VariablesT = {'1-Mg#' 'NaK#' 'TiO2'};
VariablesP = {'Oliv' '1-Mg#' 'NaK#' 'TiO2'};
VariablesX = VariablesT;

garnet_coefficients = [1320.27862	8.46845	-203.20822	-131.93741	32.94946
    0.15178	0.00607	0.24458	-0.21380	0.00061
    0.19025	-0.00026	0.07393	-0.11380	-0.01420
    0.72723	-0.00844	-0.34329	0.32331	-0.00847
    -0.02840	0.00228	-0.00210	-0.39710	0.01803
    -13.05664	132.43443	-37.43671	25.53289	0.23271];

spinel_coefficients = [1212.46356	11.96626	-96.89871	-89.35025	2.36698
    0.12541	0.00826	0.19702	-0.25988	-0.02334
    0.18135	0.00036	0.07063	-0.25490	0.00529
    0.51563	-0.00145	-0.13040	0.78183	-0.03502
    0.14882	-0.00514	-0.09775	-0.37870	0.02509
    -9.71026	99.48609	-23.82566	28.92794	2.61883];

plagioclase_coefficients = [1215.13292	10.57641	-72.53283	-198.17402	23.59003
    0.13372	0.00643	0.17128	-0.24883	-0.01182
    0.22989	-0.00312	-0.05660	-0.13940	-0.00617
    0.38970	0.02018	-0.07470	0.48483	-0.03238
    0.22515	-0.01776	-0.00339	-0.22862	0.00851
    -18.88186	145.43161	-26.04452	36.38077	1.89916];

assignin('caller', sprintf('VariablesT_%s',RegName), VariablesT)
assignin('caller', sprintf('VariablesX_%s',RegName), VariablesX)
assignin('caller', sprintf('VariablesP_%s',RegName), VariablesP)
assignin('caller', sprintf('garnet_coefficients_%s',RegName), garnet_coefficients)
assignin('caller', sprintf('spinel_coefficients_%s',RegName), spinel_coefficients)
assignin('caller', sprintf('plagioclase_coefficients_%s',RegName), plagioclase_coefficients)






